library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.5
## Warning: replacing previous import 'lifecycle::last_warnings' by
## 'rlang::last_warnings' when loading 'pillar'
## Warning: replacing previous import 'lifecycle::last_warnings' by
## 'rlang::last_warnings' when loading 'tibble'
## Warning: replacing previous import 'lifecycle::last_warnings' by
## 'rlang::last_warnings' when loading 'hms'
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.3     v dplyr   1.0.7
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   2.0.2     v forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.0.5
## Warning: package 'tibble' was built under R version 4.0.5
## Warning: package 'tidyr' was built under R version 4.0.4
## Warning: package 'readr' was built under R version 4.0.5
## Warning: package 'purrr' was built under R version 4.0.4
## Warning: package 'dplyr' was built under R version 4.0.5
## Warning: package 'stringr' was built under R version 4.0.4
## Warning: package 'forcats' was built under R version 4.0.5
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(plotly)
## Warning: package 'plotly' was built under R version 4.0.5
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(igraph)
## Warning: package 'igraph' was built under R version 4.0.5
## 
## Attaching package: 'igraph'
## The following object is masked from 'package:plotly':
## 
##     groups
## The following objects are masked from 'package:dplyr':
## 
##     as_data_frame, groups, union
## The following objects are masked from 'package:purrr':
## 
##     compose, simplify
## The following object is masked from 'package:tidyr':
## 
##     crossing
## The following object is masked from 'package:tibble':
## 
##     as_data_frame
## The following objects are masked from 'package:stats':
## 
##     decompose, spectrum
## The following object is masked from 'package:base':
## 
##     union
library(tools)
library(janitor)
## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(htmlwidgets)
## Warning: package 'htmlwidgets' was built under R version 4.0.5
library(ggthemes)
## Warning: package 'ggthemes' was built under R version 4.0.4
figure5 = read_csv("figure_5.csv") %>% 
  mutate(version = ifelse(version == "BA","Barabási Albert", "Empirical")) %>% 
  mutate(network = str_replace_all(network, "_"," ") %>% str_to_title())
## New names:
## * `` -> ...1
## Rows: 144 Columns: 6-- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (3): version, network, seeding_method
## dbl (3): ...1, N, critical_q
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
g = figure5 %>% 
  ggplot(aes(x = N, y = critical_q, colour = seeding_method, label = network)) +
  geom_point() +
  geom_line() +
  theme_classic() +
  scale_colour_tableau() +
  facet_wrap(~version) +
  labs(colour = "Seed Method", y = "Critical q") +
  ggtitle("Cascade Threshold Comparison Across Seeding Methods")


ggplotly(g) %>% 
  layout(width = 800) %>% 
  saveWidget(file = "nVScascade.html")
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()
g %>% 
  saveRDS(file = "nVScascade.RDS")
figure11 = read_csv("figure_11.csv")
## New names:
## * `` -> ...1
## Rows: 297 Columns: 4-- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): seeding_method
## dbl (3): ...1, q, proportion_adopted
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
g = figure11 %>% 
  ggplot(aes(x = q, y = proportion_adopted, colour = seeding_method)) +
  geom_point() +
  geom_line() +
  scale_colour_tableau() +
  theme_classic() +
  labs(colour = "Seed Method", y = "Proportion of Nodes Adopting Innovation") +
  ggtitle("20 Step Threshold Propagation Across q")

ggplotly(g)
g %>% 
  saveRDS(file = "qVSprop.RDS")
library(igraph)

dd <- read.table("..\\mass_data/less_than_1500_nodes/aves-weaver-social/edges.edgelist")
graph <- graph.data.frame(dd, directed=FALSE)
plot(graph)